import logging
from redis import StrictRedis


class Config(object):
    """工程配置类"""
    DEBUG = True
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/information_01"
    SQLALCHEMY_TRACK_MODIFICATIONS = False


    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379
    REDIS_NUM = 0  # 指定redis数据库

    SECRET_KEY = "sjasaj"
    SESSION_TYPE = "redis"  # 指定session保存到redis中
    SESSION_USE_SIGNER = True  # 让cookie中的session_id被加密签名处理
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT, db=REDIS_NUM)

    PERMANENT_SESSION_LIFETIME = 86400


class DevelopmentConfig(Config):
    """开发配置类"""
    DEBUG = True
    LOG_LEVEL = logging.DEBUG


class ProductConfig(Config):
    """生产配置类"""
    DEBUG = False

    LOG_LEVEL = logging.WARNING


# 提供一个接口暴露给外界使用
config_dict = {
    "development": DevelopmentConfig,
    "product": ProductConfig
}
